import { OmitDto, PickDto, Rule, RuleType } from '@midwayjs/validate';
import { PagingInfo } from './images';

export class UserDTO {
  @Rule(RuleType.string().required().max(20))
  name: string;
  @Rule(RuleType.string().required().email())
  email: string;
  @Rule(RuleType.string().required().min(6))
  password: string;
  @Rule(RuleType.number().valid(0, 1).default(1))
  status: 0 | 1;
}

//PickDto 用于从现有的 DTO 中获取一些属性，变成新的 DTO，而 OmitDto 用于将其中某些属性剔除
export class registerUserDTO extends OmitDto(UserDTO, ['status']) {
}

export class loginDTO extends PickDto(UserDTO, ['email', 'password']) {
}

export class updateDTO {
  @Rule(RuleType.number().required())
  id: number;
  @Rule(RuleType.string().max(20))
  name: string;
  @Rule(RuleType.number().valid(0, 1))
  status?: number;
  @Rule(RuleType.string().email())
  email?: string;
  @Rule(RuleType.string().min(6))
  password?: string;
}

export class getUserListDTO extends PagingInfo {
  @Rule(RuleType.string())
  user: string;
}



export class updateUserDTO extends OmitDto(updateDTO, ['email']) {
}
